cmake_minimum_required(VERSION 3.15)

project(cuda_fast LANGUAGES CXX CUDA)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC -Wall")

# find package which are needed in project
include(${CMAKE_SOURCE_DIR}/cmake/FindPackage.cmake)

# NVCC flags
# if (CMAKE_BUILD_TYPE STREQUAL "Debug")
#   set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};-gencode;arch=compute_35,code=sm_35;
#       -gencode;arch=compute_52,code=sm_52;
#       -gencode;arch=compute_50,code=compute_50;
#       -std=c++11;-g;-lineinfo;-Xcompiler;-ggdb)
# else()
#   set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};-gencode;arch=compute_35,code=sm_35;
#       -gencode;arch=compute_52,code=sm_52;
#       -gencode;arch=compute_50,code=compute_50;
#       -std=c++11;-O3;-DNDEBUG;-Xcompiler;-DNDEBUG)
# endif()

add_executable(hello_world 
    01_hello_world/main.cpp 
    01_hello_world/hello_world.h
    01_hello_world/hello_world.cu)

add_executable(rgb2gray 
    02_rgb2gray/main.cu)
target_link_libraries(rgb2gray ${OpenCV_LIBS})


# exe for image blur
file(GLOB blur_files 03_blur/*h 03_blur/*cpp 03_blur/*cu)
add_executable(blur ${blur_files})
target_link_libraries(blur ${OpenCV_LIBS})

# exe for tone mapping
file(GLOB tone_mapping_files 
    04_toneMapping/*h 
    04_toneMapping/*cpp 
    04_toneMapping/*cu)
add_executable(tone_mapping ${tone_mapping_files})
target_link_libraries(tone_mapping ${OpenCV_LIBS})

# workspace
add_executable(workspace workspace/main.cpp workspace/part.cpp)
add_executable(reduce_test workspace/reduce_test.cu)
add_executable(h_scan workspace/hillis_steele_scan.cu)
add_executable(b_scan workspace/blelloch_scan.cu)